﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.UI;
using ARchGL.Platform.Electrocar.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARchGL.Platform.Electrocar.Application
{
    /// <summary>
    /// 
    /// </summary>
    public class BaseService :ApplicationService
    {
        protected PagedResultDto<T> Response<T>(dynamic query, dynamic result)
        {
            return new PagedResultDto<T>(query.Count(),
                ObjectMapper.Map<List<T>>(result.ToList()));
        }

        #region Install

        #endregion

        #region System

        public void WriteLine(string str)
        {
            Console.WriteLine(str);
        }

        /// <summary>
        /// 获取实体上的数据库表名
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public object GetTableName<T>()
        {
            return typeof(T).CustomAttributes.FirstOrDefault().ConstructorArguments.FirstOrDefault().Value;
        }

        #endregion
    }
}
